import Vue from "vue";
import Vuex from "vuex";
import Constant from "./constant";

Vue.use(Vuex);

//vuex
export const store = new Vuex.Store({
    state: {
        // name: '111',
        no: 0,
        list: []
    },
    mutations: {
        [Constant.CLEAR_LIST]: (state) => {
            state.list = [];
        },
        [Constant.DELETE_DIARY]: (state, payload) => {
            state.list.splice(payload.index, 1);
        },
        [Constant.REVISE_DIARY]: (state, payload) => {
            state.list[payload.list.no] = payload.list;
        }
    }
});